<?php
namespace app\index\controller;
use think\Request;
use think\Loader;
class User extends Base{
    /*
    * 初始化操作
    */
    public function _initialize()
    {
        parent::_initialize();
        $nologin = array(
            'reg',
            'login',
            'regprotocol',
            'forgetpassword',
        );
        $user       = session('lt_user');
        $request    = Request::instance();//获取请求类型
        if ($user && in_array($request->action(), $nologin)) {
            header("location:" . url('index/user/index'));
            exit;
        }else{
            if(!$user && !in_array($request->action(), $nologin)){
                exit(header("location:" . url('/index/index')));
            }
        }
        $this->assign('user_css',1);
        $this->assign('sie',pageSie(8));//页面描述与关键字
    }
    // 用户注册
    public function reg()
    {
      return $this->fetch();
    }

    // 用户登录
    public function login()
    {
      return $this->fetch();
    }

    // 注册协议
    public function regprotocol()
    {
      return $this->fetch();
    }

    // 忘记密码
    public function forgetpassword()
    {

      return $this->fetch();
    }

    // 用户中心
    public function index()
    {
      return $this->fetch();
    }

    // 我的服务
    public function myservice()
    {
        $invoking                    = Loader::model('User','service');
        $data                        = $invoking->userCounselorOrder();
        $this->assign('list',$data['list']);
        $this->assign('page',$data['page']);
        $this->assign('user_css',3);
        return $this->fetch();
    }

    // 我的订单
    public function myorder()
    {
        $invoking                    = Loader::model('User','service');
        $data                        = $invoking->userOrder();
        $this->assign('list',$data['list']);
        $this->assign('page',$data['page']);
        $this->assign('user_css',4);
        return $this->fetch();
    }

    //未付款
    public function not_myorder(){
        $invoking                    = Loader::model('User','service');
        $data                        = $invoking->userOrder(1);
        $this->assign('list',$data['list']);
        $this->assign('page',$data['page']);
        $this->assign('user_css',4);
        return $this->fetch();
    }

    // 我的收藏
    public function mycollect()
    {
        $invoking                    = Loader::model('User','service');
        $data                        = $invoking->userNewsCollect();
        $this->assign('list',$data['list']);
        $this->assign('page',$data['page']);
        $this->assign('user_css',5);
        return $this->fetch();
    }

    // 我的咨询
    public function myquestion()
    {
        $invoking                    = Loader::model('User','service');
        $data                        = $invoking->userMyquestion();
        $this->assign('list',$data['list']);
        $this->assign('page',$data['page']);
        $this->assign('user_css',2);
        return $this->fetch();
    }

    // 修改密码
    public function modpassword()
    {
        $this->assign('user_css',6);
        return $this->fetch();
    }
}
